package cn.openea.perpartner.meily.constant.enums;

import cn.openea.perpartner.meily.constant.CommonConstants;
import cn.openea.perpartner.meily.web.entity.dto.EnterpriseDtoFactory;
import cn.openea.perpartner.meily.web.entity.dto.GroupBuyingSubDTOFactory.ShipmentTemplateDTO;
import cn.openea.perpartner.meily.web.entity.dto.GroupBuyingSubDTOFactory.SupplyPriceTemplateDTO;
import cn.openea.perpartner.meily.web.entity.dto.ProvideSamplesSubDTOFactory.SamplesShipmentTemplateDTO;
import cn.openea.perpartner.meily.web.entity.dto.TrialEvaluationSubShipmentDTO;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author ysk
 * @version 1.0.1
 * @Description 导入导出动作
 * @createTime 2023年05月15日 16:21:00
 */
@Getter
public enum ImportAndExportActions {

    /**
     * 测评批量发货
     */
    EVALUATION_BATCH_DELIVERY(CommonConstants.IMPORTANDEXPORT.EVALUATION_BATCH_DELIVERY, "测评批量发货", TrialEvaluationSubShipmentDTO.class),
    /**
     * 团购批量发货
     */
    GROUPBUY_BATCH_DELIVERY(CommonConstants.IMPORTANDEXPORT.GROUPBUY_BATCH_DELIVERY, "团购批量发货", ShipmentTemplateDTO.class),
    /**
     * 团购录入供货价
     */
    GROUPBUY_ENTER_SUPPLYPRICE(CommonConstants.IMPORTANDEXPORT.GROUPBUY_ENTER_SUPPLYPRICE, "团购录入供货价", SupplyPriceTemplateDTO.class),
    /**
     * 样品批量发货
     */
    SAMPLE_BATCH_DELIVERY(CommonConstants.IMPORTANDEXPORT.SAMPLE_BATCH_DELIVERY, "样品批量发货", SamplesShipmentTemplateDTO.class),
    /**
     * 企业导入导出
     */
    ENTERPRISE_IMPORT(CommonConstants.IMPORTANDEXPORT.ENTERPRISE_IMPORT, "企业数据导入", EnterpriseDtoFactory.ImportTemplateDto.class),
    ;

    /**
     * 动作编码
     */
    private final String code;

    /**
     * 备注
     */
    private final String remark;

    /**
     * 模板类型
     */
    private final Class tClass;

    ImportAndExportActions(String code, String remark, Class tClass) {
        this.code = code;
        this.remark = remark;
        this.tClass = tClass;
    }

    public static ImportAndExportActions getByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (ImportAndExportActions value : values()) {
            if (code.equals(value.getCode())) {
                return value;
            }
        }
        return null;
    }
}
